package com.lekang.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lekang.common.annotation.Log;
import com.lekang.common.core.controller.BaseController;
import com.lekang.common.core.domain.AjaxResult;
import com.lekang.common.enums.BusinessType;
import com.lekang.system.domain.PrepaymentRecharge;
import com.lekang.system.service.IPrepaymentRechargeService;
import com.lekang.common.utils.poi.ExcelUtil;
import com.lekang.common.core.page.TableDataInfo;

/**
 * 预缴款充值Controller
 * 
 * @author 刘卓
 * @date 2025-10-13
 */
@RestController
@RequestMapping("/system/recharge")
public class PrepaymentRechargeController extends BaseController
{
    @Autowired
    private IPrepaymentRechargeService prepaymentRechargeService;

    /**
     * 查询预缴款充值列表
     */
    @PreAuthorize("@ss.hasPermi('system:recharge:list')")
    @GetMapping("/list")
    public TableDataInfo list(PrepaymentRecharge prepaymentRecharge)
    {
        startPage();
        List<PrepaymentRecharge> list = prepaymentRechargeService.selectPrepaymentRechargeList(prepaymentRecharge);
        return getDataTable(list);
    }

    /**
     * 导出预缴款充值列表
     */
    @PreAuthorize("@ss.hasPermi('system:recharge:export')")
    @Log(title = "预缴款充值", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PrepaymentRecharge prepaymentRecharge)
    {
        List<PrepaymentRecharge> list = prepaymentRechargeService.selectPrepaymentRechargeList(prepaymentRecharge);
        ExcelUtil<PrepaymentRecharge> util = new ExcelUtil<PrepaymentRecharge>(PrepaymentRecharge.class);
        util.exportExcel(response, list, "预缴款充值数据");
    }

    /**
     * 获取预缴款充值详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:recharge:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(prepaymentRechargeService.selectPrepaymentRechargeById(id));
    }

    /**
     * 新增预缴款充值
     */
    @PreAuthorize("@ss.hasPermi('system:recharge:add')")
    @Log(title = "预缴款充值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PrepaymentRecharge prepaymentRecharge)
    {
        return toAjax(prepaymentRechargeService.insertPrepaymentRecharge(prepaymentRecharge));
    }

    /**
     * 修改预缴款充值
     */
    @PreAuthorize("@ss.hasPermi('system:recharge:edit')")
    @Log(title = "预缴款充值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PrepaymentRecharge prepaymentRecharge)
    {
        return toAjax(prepaymentRechargeService.updatePrepaymentRecharge(prepaymentRecharge));
    }

    /**
     * 删除预缴款充值
     */
    @PreAuthorize("@ss.hasPermi('system:recharge:remove')")
    @Log(title = "预缴款充值", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(prepaymentRechargeService.deletePrepaymentRechargeByIds(ids));
    }
}
